package ipebg.mzk.provider.rabbitmq.consumer.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.ObjectMapper;

@Component("jiabanMessageListener")
public class JiabanMessageListener implements MessageListener {

	@Override
	public void onMessage(Message msg) {
		try {
			ObjectMapper mapper = new ObjectMapper(); 
			String jsonStr = new String(msg.getBody());
			Map<String, Object> objs= (Map<String, Object>) mapper.readValue(jsonStr ,HashMap.class);
			Object item = objs.get("item");
			Object data = objs.get("data");
			System.out.println("-------------------------------------------------------------");
			System.out.println(item.toString());
			System.out.println(data.toString());
			Thread.sleep(500l);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
